package servlets;

import beans.Unit_Beans;
import beans.Unit_Logic_Beans;
import jakarta.servlet.ServletException;
import jakarta.servlet.annotation.WebServlet;
import jakarta.servlet.http.HttpServlet;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;

import java.io.IOException;
import java.util.Arrays;
import java.util.List;

@WebServlet(name = "ajax1",urlPatterns = "/ajax1")
public class Ajax_Servlet extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        String UNITACCNUM = req.getParameter("name");
        Unit_Beans unit_beans = new Unit_Beans();
        unit_beans.setUNITACCNUM(UNITACCNUM);

        Unit_Logic_Beans unit_logic_beans = new Unit_Logic_Beans();
        List<Unit_Beans> list = unit_logic_beans.Select_Unit(unit_beans);

        if (!(list.isEmpty())){
            resp.getWriter().print(list.get(0));
        }
        else{
            resp.getWriter().print("未查询到公司信息！");
        }
    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        super.doPost(req, resp);
    }
}
